import { View, Image } from '@tarojs/components';
import Taro from '@tarojs/taro';
import Title from '@/components/Title/index';
import Price from '@/components/Price';
import './index.scss';

export default function ({ miaoshaList }) {
  const onHandle = () => {
    Taro.navigateTo({
      url: '/subPages/miaosha/index',
    });
  };

  const toDetailPage = (id: string) => {
    Taro.navigateTo({
      url: '/subPages/miaosha/detail/index?miaoshaId=' + id,
    });
  };
  return (
    <View className="home-miaosha">
      <Title
        title="限时秒杀"
        subTitle="/  只给家人们的实惠"
        rightText="更多"
        onHandleRight={onHandle}
      />
      <View className="goods-list">
        {miaoshaList.map((goods) => {
          return (
            <View className="goods-item" key={goods.id} onClick={() => toDetailPage(goods.id)}>
              <Image className="goods-image" mode="aspectFill" src={goods.pic_url} />
              {/* <View className="goods-title">{goods.name}</View> */}
              <Price color="#333333" price={goods.goods_price} />
            </View>
          );
        })}
      </View>
    </View>
  );
}
